***************************************************************************************************************
	
	/* Empirical results in article "Competition and Productivity: Evidence from Peruvian Municipalities" */
	
***************************************************************************************************************

***********************
	/* Databases */
***********************

/* Firm-level data from the Annual Economic Survey (EEA) collected by Peru's National Institute of Statistics (INEI) for the 2007-17 period; public available at: http://iinei.inei.gob.pe/microdatos. The raw data have been used as described in the article and the attached file "Readme file data for ReStat". */

/* Eliminated regulatory barriers from the Peru Competition Authority (Instituto Nacional de Defensa de la Competencia y de la Protección de la Propiedad Intelectual – INDECOPI); publicly  available at: https://indecopi.gob.pe/estadisticas. The raw data have been used as described in the article and the attached file "Readme file data for ReStat". */

/* The eliminated regulatory barriers data have been merged with the firm-level data at the municipality-sector level using publicly available 6-digit location codes for municipalities and 4-digit NACE Rev.4 sector codes. The merged dataset used for the empirical analysis is attached: "Peru Competition and productivity 2007-2017.dta" */



*********************************************
	/* Empirical Results in the article */
*********************************************

cd "C:\Users\WB348373\OneDrive - WBG\Documents\Peru\Research notes FY17\Competition and productivity\"
use "Stata\Peru Competition and productivity 2007-2017.dta", clear

log using "Stata\Results in paper", replace

***Table 1: Descriptive statistics:
sum ruc tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref va empl cap interm wage age

***Table 2: Impact of eliminating sector-specific local entry barriers (baseline results):
foreach y of var tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref {
	reghdfe `y' rsub_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
}

***Table 3: Impact on firms in reform-sectors relative to other firms in reform-municipality: 
foreach y of var tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref {
	reghdfe `y' rsub_isic2_dummy age, absorb(i.ruc i.year##i.ccddppdi) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy age, absorb(i.ruc i.year##i.ccddppdi) vce(cluster i.isic2_ccddppdi) noconstant
}
***Table 4: Test of parallel trend assumption:
tsset ruc year
foreach y of var rsub_isic2_dummy rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy rsub_dummy rsublic_dummy rsubotro_dummy rsubcobro_dummy {
	gen `y'ct = `y'
	replace `y'ct = 1 if year==2008 & (F5.`y'==1 | F6.`y'==1 | F7.`y'==1)
	replace `y'ct = 1 if year==2009 & (F4.`y'==1 | F5.`y'==1 | F6.`y'==1)
	replace `y'ct = 1 if year==2010 & (F3.`y'==1 | F4.`y'==1 | F5.`y'==1)
	replace `y'ct = 1 if year==2011 & (F2.`y'==1 | F3.`y'==1 | F4.`y'==1)
	replace `y'ct = 1 if year==2012 & (F1.`y'==1 | F2.`y'==1 | F3.`y'==1)
	replace `y'ct = 1 if year==2013 & (F1.`y'==1 | F2.`y'==1)
}
foreach y of var tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref {
	***Province*year and sector*year dummies:
	reghdfe `y' rsub_isic2_dummy F1.rsub_isic2_dummy F2.rsub_isic2_dummy F3.rsub_isic2_dummy F4.rsub_isic2_dummy F5.rsub_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	test F2.rsub_isic2_dummy F3.rsub_isic2_dummy F4.rsub_isic2_dummy F5.rsub_isic2_dummy
	*
	reghdfe `y' rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy F1.rsublic_isic2_dummy F1.rsubotro_isic2_dummy F1.rsubcobro_isic2_dummy F2.rsublic_isic2_dummy F2.rsubotro_isic2_dummy F2.rsubcobro_isic2_dummy F3.rsublic_isic2_dummy F3.rsubotro_isic2_dummy F3.rsubcobro_isic2_dummy F4.rsublic_isic2_dummy F4.rsubotro_isic2_dummy F4.rsubcobro_isic2_dummy F5.rsublic_isic2_dummy F5.rsubotro_isic2_dummy F5.rsubcobro_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	test F2.rsublic_isic2_dummy F3.rsublic_isic2_dummy F4.rsublic_isic2_dummy F5.rsublic_isic2_dummy
	test F2.rsubotro_isic2_dummy F3.rsubotro_isic2_dummy F4.rsubotro_isic2_dummy F5.rsubotro_isic2_dummy
	test F2.rsubcobro_isic2_dummy F3.rsubcobro_isic2_dummy F4.rsubcobro_isic2_dummy F5.rsubcobro_isic2_dummy
	***Municipality*year dummies:
	reghdfe `y' rsub_isic2_dummy F1.rsub_isic2_dummy F2.rsub_isic2_dummy F3.rsub_isic2_dummy F4.rsub_isic2_dummy F5.rsub_isic2_dummy age, absorb(i.ruc i.year##i.ccddppdi) vce(cluster i.isic2_ccddppdi) noconstant
	test F2.rsub_isic2_dummy F3.rsub_isic2_dummy F4.rsub_isic2_dummy F5.rsub_isic2_dummy
	*
	reghdfe `y' rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy F1.rsublic_isic2_dummy F1.rsubotro_isic2_dummy F1.rsubcobro_isic2_dummy F2.rsublic_isic2_dummy F2.rsubotro_isic2_dummy F2.rsubcobro_isic2_dummy F3.rsublic_isic2_dummy F3.rsubotro_isic2_dummy F3.rsubcobro_isic2_dummy F4.rsublic_isic2_dummy F4.rsubotro_isic2_dummy F4.rsubcobro_isic2_dummy F5.rsublic_isic2_dummy F5.rsubotro_isic2_dummy F5.rsubcobro_isic2_dummy age, absorb(i.ruc i.year##i.ccddppdi) vce(cluster i.isic2_ccddppdi) noconstant
	test F2.rsublic_isic2_dummy F3.rsublic_isic2_dummy F4.rsublic_isic2_dummy F5.rsublic_isic2_dummy
	test F2.rsubotro_isic2_dummy F3.rsubotro_isic2_dummy F4.rsubotro_isic2_dummy F5.rsubotro_isic2_dummy
	test F2.rsubcobro_isic2_dummy F3.rsubcobro_isic2_dummy F4.rsubcobro_isic2_dummy F5.rsubcobro_isic2_dummy
}

***Figure 1: Impact of eliminating local entry barriers:
fvset base 2012 year
reghdfe tfp_cd_ref rsub_isic2_dummyct##i.year age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
coefplot, keep(1.rsub_isic2_dummyct#*.year) drop(_cons) vertical ci(95) xtitle(year) ytitle(Impact on firm productivity) coeflabels(1.rsub_isic2_dummyct#2008.year="2008" 1.rsub_isic2_dummyct#2009.year="2009" 1.rsub_isic2_dummyct#2010.year="2010" 1.rsub_isic2_dummyct#2011.year="2011" 1.rsub_isic2_dummyct#2012.year="2012" 1.rsub_isic2_dummyct#2013.year="2013" 1.rsub_isic2_dummyct#2014.year="2014" 1.rsub_isic2_dummyct#2015.year="2015" 1.rsub_isic2_dummyct#2016.year="2016" 1.rsub_isic2_dummyct#2017.year="2017") xline(4.75, lpattern(dash)) yline(0) recast(connected) mlabel(cond(@pval<.01, "***", cond(@pval<.05, "**", cond(@pval<.1, "*", cond(@pval<.05, "", "")))))
graph export "Common-trend-test_year-province-dummies_coefplot2008-17_vs2012.tif", as(tif) replace

log close



*****************************************************************
	/* Empirical Results in the web appendix to the article */
*****************************************************************

log using "Stata\Results in web appendix", replace

***Table A.1: Sector-specific municipal reforms: treatment versus control:
forval num = 13/17 {
	preserve
	keep if year==20`num'
	collapse year rsub_dummy rsub_isic2_dummy, by(ccddppdi)
	sum year rsub_isic2_dummy if rsub_isic2_dummy>0		/* treatment: total number of reform municipalities */
	restore
}
forval num = 13/17 {
	preserve
	keep if year==20`num'
	collapse year rsub_isic2_dummy, by(isic2)
	sum year rsub_isic2_dummy if rsub_isic2_dummy>0		/* treatment: total number of reform sectors */
	restore
}
forval num = 13/17 {
	preserve
	keep if year==20`num'
	collapse year rsub_isic2_dummy ccdd ccddpp, by(ccddppdi isic2)
	sum year rsub_isic2_dummy if rsub_isic2_dummy>0		/* treatment: total number of reform municipalities*sectors */
	sum year rsub_isic2_dummy if rsub_isic2_dummy==0		/* control: total number of non-reform municipalities*sectors */
	bysort isic2: egen isic2_ref = mean(rsub_isic2_dummy)
	sum year rsub_isic2_dummy if isic2_ref>0 & rsub_isic2_dummy==0		/* control: average number of non-reform municipalities by reform-sectors */
	bysort isic2 ccdd: egen isic2_ccdd_ref = mean(rsub_isic2_dummy)
	sum year rsub_isic2_dummy if isic2_ccdd_ref>0 & rsub_isic2_dummy==0		/* control: average number of non-reform municipalities by reform-sector in reform states */
	bysort isic2 ccddpp: egen isic2_ccddpp_ref = mean(rsub_isic2_dummy)
	sum year rsub_isic2_dummy if isic2_ccddpp_ref>0 & rsub_isic2_dummy==0		/* control: average number of non-reform municipalities by reform-sector in reform provinces */
	restore
}
forval num = 13/17 {
	sum year rsub_isic2_dummy if rsub_isic2_dummy==1 & year==20`num'		/* treatment: total number of firms */
	sum year rsub_isic2_dummy if rsub_isic2_dummy==0 & year==20`num'		/* control: total number of firms */
}
forval num = 13/17 {
	preserve
	keep if year==20`num'
	gen control_firm = 0
	replace control_firm = 1 if rsub_isic2_dummy==0
	collapse (sum) rsub_isic2_dummy control_firm, by (year ccddppdi isic2)
	sum year rsub_isic2_dummy if rsub_isic2_dummy>=1		/* treatment: average number firms */
	restore
}
forval num = 13/17 {
	preserve
	keep if year==20`num'
	gen control_firm = 0
	replace control_firm = 1 if rsub_isic2_dummy==0
	collapse (sum) rsub_isic2_dummy control_firm, by (year isic2)
	sum year control_firm if control_firm>0 & rsub_isic2_dummy>0		/* control: average number of firms in non-reform municipalities & reform-sectors */
	restore
}
forval num = 13/17 {
	preserve
	keep if year==20`num'
	gen control_firm = 0
	replace control_firm = 1 if rsub_isic2_dummy==0
	collapse (sum) rsub_isic2_dummy control_firm, by (year ccdd isic2)
	sum year control_firm if control_firm>0 & rsub_isic2_dummy>0		/* control: average number of firms in non-reform municipalities & reform-sectors in reform states */
	restore
}
forval num = 13/17 {
	preserve
	keep if year==20`num'
	gen control_firm = 0
	replace control_firm = 1 if rsub_isic2_dummy==0
	collapse (sum) rsub_isic2_dummy control_firm, by (year ccddpp isic2)
	sum year control_firm if control_firm>0 & rsub_isic2_dummy>0		/* control: average number of firms in non-reform municipalities & reform-sectors in reform provinces */
	restore
}

***Table A.2: Summary statistics firm census data for outcome variables by economic activity:
sum ruc tfp_tl_ref tfp_cd_ref if (isic2>=10 & isic2<=33)
sum ruc tfp_tl_ref tfp_cd_ref if isic2==10
sum ruc tfp_tl_ref tfp_cd_ref if (isic2>=35 & isic2<=39)
sum ruc tfp_tl_ref tfp_cd_ref if (isic2>=40 & isic2<=43)
sum ruc tfp_tl_ref tfp_cd_ref if (isic2>=45 & isic2<=47)
sum ruc tfp_tl_ref tfp_cd_ref if (isic2>=49 & isic2<=53)
sum ruc tfp_tl_ref tfp_cd_ref if (isic2>=58 & isic2<=63)
sum ruc tfp_tl_ref tfp_cd_ref if isic2>=68
sum ruc Markup_tl_ref markup_tl_ref if markup_tl_ref!=. & (isic2>=10 & isic2<=33)
sum ruc Markup_tl_ref markup_tl_ref if markup_tl_ref!=. & isic2==10
sum ruc Markup_tl_ref markup_tl_ref if markup_tl_ref!=. & (isic2>=35 & isic2<=39)
sum ruc Markup_tl_ref markup_tl_ref if markup_tl_ref!=. & (isic2>=40 & isic2<=43)
sum ruc Markup_tl_ref markup_tl_ref if markup_tl_ref!=. & (isic2>=45 & isic2<=47)
sum ruc Markup_tl_ref markup_tl_ref if markup_tl_ref!=. & (isic2>=49 & isic2<=53)
sum ruc Markup_tl_ref markup_tl_ref if markup_tl_ref!=. & (isic2>=58 & isic2<=63)
sum ruc Markup_tl_ref markup_tl_ref if markup_tl_ref!=. & isic2>=68
sum ruc Markup_cd_ref markup_cd_ref if markup_cd_ref!=. & (isic2>=10 & isic2<=33)
sum ruc Markup_cd_ref markup_cd_ref if markup_cd_ref!=. & isic2==10
sum ruc Markup_cd_ref markup_cd_ref if markup_cd_ref!=. & (isic2>=35 & isic2<=39)
sum ruc Markup_cd_ref markup_cd_ref if markup_cd_ref!=. & (isic2>=40 & isic2<=43)
sum ruc Markup_cd_ref markup_cd_ref if markup_cd_ref!=. & (isic2>=45 & isic2<=47)
sum ruc Markup_cd_ref markup_cd_ref if markup_cd_ref!=. & (isic2>=49 & isic2<=53)
sum ruc Markup_cd_ref markup_cd_ref if markup_cd_ref!=. & (isic2>=58 & isic2<=63)
sum ruc Markup_cd_ref markup_cd_ref if markup_cd_ref!=. & isic2>=68

***Table A.3: Summary statistics sector-specific municipal reforms: treatment versus control:
bysort isic2: egen rsub_isic2_dummyct_isic2 = sum(rsub_isic2_dummyct)
bysort ccdd: egen rsub_isic2_dummyct_ccdd = sum(rsub_isic2_dummyct)
bysort ccddpp: egen rsub_isic2_dummyct_ccddpp = sum(rsub_isic2_dummyct)
foreach y of var tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref {
	forval num = 2008/2017 {
		sum year `y' if rsub_isic2_dummyct==1 & year==`num'
		sum year `y' if rsub_isic2_dummyct==0 & year==`num'		/*Mean non-reform municipalities, all sectors and states*/	
	}
}

***Table A.4: Impact of eliminating sector-specific local entry barriers -- baseline results extended:
foreach y of var tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref {
	reghdfe `y' rsub_isic2_dummy age, absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy age, absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsublic_isic2_dummy age if (rsubotro_isic2_dummy==0 & rsubcobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsubotro_isic2_dummy age if (rsublic_isic2_dummy==0 & rsubcobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsubcobro_isic2_dummy age if (rsublic_isic2_dummy==0 & rsubotro_isic2_dummy==0), absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsublic_isic2_dummy age if (rsubotro_isic2_dummy==0 & rsubcobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsubotro_isic2_dummy age if (rsublic_isic2_dummy==0 & rsubcobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsubcobro_isic2_dummy age if (rsublic_isic2_dummy==0 & rsubotro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
}

***Table A.5: Impact on firms in reform sectors relative to other firms in the same reform-municipality extended:
foreach y of var tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref {
	reghdfe `y' rsub_isic2_dummy age, absorb(i.ruc i.year##i.ccddppdi) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy age, absorb(i.ruc i.year##i.ccddppdi) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsublic_isic2_dummy age if (rsubotro_isic2_dummy==0 & rsubcobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddppdi) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsubotro_isic2_dummy age if (rsublic_isic2_dummy==0 & rsubcobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddppdi) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsubcobro_isic2_dummy age if (rsublic_isic2_dummy==0 & rsubotro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddppdi) vce(cluster i.isic2_ccddppdi) noconstant
}

***Table A.6: Test of parallel trend assumption extended:
sort ruc year
foreach y of var tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref {
	***State*year and sector*year dummies:
	reghdfe `y' rsub_isic2_dummy F1.rsub_isic2_dummy F2.rsub_isic2_dummy F3.rsub_isic2_dummy F4.rsub_isic2_dummy F5.rsub_isic2_dummy age, absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	test F2.rsub_isic2_dummy F3.rsub_isic2_dummy F4.rsub_isic2_dummy F5.rsub_isic2_dummy
	*
	reghdfe `y' rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy F1.rsublic_isic2_dummy F1.rsubotro_isic2_dummy F1.rsubcobro_isic2_dummy F2.rsublic_isic2_dummy F2.rsubotro_isic2_dummy F2.rsubcobro_isic2_dummy F3.rsublic_isic2_dummy F3.rsubotro_isic2_dummy F3.rsubcobro_isic2_dummy F4.rsublic_isic2_dummy F4.rsubotro_isic2_dummy F4.rsubcobro_isic2_dummy F5.rsublic_isic2_dummy F5.rsubotro_isic2_dummy F5.rsubcobro_isic2_dummy age, absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	test F2.rsublic_isic2_dummy F3.rsublic_isic2_dummy F4.rsublic_isic2_dummy F5.rsublic_isic2_dummy
	test F2.rsubotro_isic2_dummy F3.rsubotro_isic2_dummy F4.rsubotro_isic2_dummy F5.rsubotro_isic2_dummy
	test F2.rsubcobro_isic2_dummy F3.rsubcobro_isic2_dummy F4.rsubcobro_isic2_dummy F5.rsubcobro_isic2_dummy
	***Province*year and sector*year dummies:
	reghdfe `y' rsub_isic2_dummy F1.rsub_isic2_dummy F2.rsub_isic2_dummy F3.rsub_isic2_dummy F4.rsub_isic2_dummy F5.rsub_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	test F2.rsub_isic2_dummy F3.rsub_isic2_dummy F4.rsub_isic2_dummy F5.rsub_isic2_dummy
	*
	reghdfe `y' rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy F1.rsublic_isic2_dummy F1.rsubotro_isic2_dummy F1.rsubcobro_isic2_dummy F2.rsublic_isic2_dummy F2.rsubotro_isic2_dummy F2.rsubcobro_isic2_dummy F3.rsublic_isic2_dummy F3.rsubotro_isic2_dummy F3.rsubcobro_isic2_dummy F4.rsublic_isic2_dummy F4.rsubotro_isic2_dummy F4.rsubcobro_isic2_dummy F5.rsublic_isic2_dummy F5.rsubotro_isic2_dummy F5.rsubcobro_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	test F2.rsublic_isic2_dummy F3.rsublic_isic2_dummy F4.rsublic_isic2_dummy F5.rsublic_isic2_dummy
	test F2.rsubotro_isic2_dummy F3.rsubotro_isic2_dummy F4.rsubotro_isic2_dummy F5.rsubotro_isic2_dummy
	test F2.rsubcobro_isic2_dummy F3.rsubcobro_isic2_dummy F4.rsubcobro_isic2_dummy F5.rsubcobro_isic2_dummy
	***Municipality*year dummies:
	reghdfe `y' rsub_isic2_dummy F1.rsub_isic2_dummy F2.rsub_isic2_dummy F3.rsub_isic2_dummy F4.rsub_isic2_dummy F5.rsub_isic2_dummy age, absorb(i.ruc i.year##i.ccddppdi) vce(cluster i.isic2_ccddppdi) noconstant
	test F2.rsub_isic2_dummy F3.rsub_isic2_dummy F4.rsub_isic2_dummy F5.rsub_isic2_dummy
	*
	reghdfe `y' rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy F1.rsublic_isic2_dummy F1.rsubotro_isic2_dummy F1.rsubcobro_isic2_dummy F2.rsublic_isic2_dummy F2.rsubotro_isic2_dummy F2.rsubcobro_isic2_dummy F3.rsublic_isic2_dummy F3.rsubotro_isic2_dummy F3.rsubcobro_isic2_dummy F4.rsublic_isic2_dummy F4.rsubotro_isic2_dummy F4.rsubcobro_isic2_dummy F5.rsublic_isic2_dummy F5.rsubotro_isic2_dummy F5.rsubcobro_isic2_dummy age, absorb(i.ruc i.year##i.ccddppdi) vce(cluster i.isic2_ccddppdi) noconstant
	test F2.rsublic_isic2_dummy F3.rsublic_isic2_dummy F4.rsublic_isic2_dummy F5.rsublic_isic2_dummy
	test F2.rsubotro_isic2_dummy F3.rsubotro_isic2_dummy F4.rsubotro_isic2_dummy F5.rsubotro_isic2_dummy
	test F2.rsubcobro_isic2_dummy F3.rsubcobro_isic2_dummy F4.rsubcobro_isic2_dummy F5.rsubcobro_isic2_dummy
}

***Figure A.4: Impact of eliminating local entry barriers extended:
fvset base 2012 year
reghdfe tfp_cd_ref rsub_isic2_dummyct##i.year age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
coefplot, keep(1.rsub_isic2_dummyct#*.year) drop(_cons) vertical ci(95) xtitle(year) ytitle(Impact on firm productivity) coeflabels(1.rsub_isic2_dummyct#2008.year="2008" 1.rsub_isic2_dummyct#2009.year="2009" 1.rsub_isic2_dummyct#2010.year="2010" 1.rsub_isic2_dummyct#2011.year="2011" 1.rsub_isic2_dummyct#2012.year="2012" 1.rsub_isic2_dummyct#2013.year="2013" 1.rsub_isic2_dummyct#2014.year="2014" 1.rsub_isic2_dummyct#2015.year="2015" 1.rsub_isic2_dummyct#2016.year="2016" 1.rsub_isic2_dummyct#2017.year="2017") xline(4.75, lpattern(dash)) yline(0) recast(connected) mlabel(cond(@pval<.01, "***", cond(@pval<.05, "**", cond(@pval<.1, "*", cond(@pval<.05, "", "")))))
graph export "Common-trend-test_year-province-dummies_coefplot2008-17_vs2012.tif", as(tif) replace
*
fvset base 2012 year
reghdfe tfp_cd_ref rsub_isic2_dummyct##i.year age, absorb(i.ruc i.year##i.ccddppdi) vce(cluster i.isic2_ccddppdi) noconstant
coefplot, keep(1.rsub_isic2_dummyct#*.year) drop(_cons) vertical ci(95) xtitle(year) ytitle(Impact on firm productivity) coeflabels(1.rsub_isic2_dummyct#2008.year="2008" 1.rsub_isic2_dummyct#2009.year="2009" 1.rsub_isic2_dummyct#2010.year="2010" 1.rsub_isic2_dummyct#2011.year="2011" 1.rsub_isic2_dummyct#2012.year="2012" 1.rsub_isic2_dummyct#2013.year="2013" 1.rsub_isic2_dummyct#2014.year="2014" 1.rsub_isic2_dummyct#2015.year="2015" 1.rsub_isic2_dummyct#2016.year="2016" 1.rsub_isic2_dummyct#2017.year="2017") xline(4.75, lpattern(dash)) yline(0) recast(connected) mlabel(cond(@pval<.01, "***", cond(@pval<.05, "**", cond(@pval<.1, "*", cond(@pval<.05, "", "")))))
graph export "Common-trend-test_year-municipality-dummies_coefplot2008-17_vs2012.tif", as(tif) replace

***Table A.7: Robustness: Controlling for province/municipality specific trends:
gen trend = year-2006
foreach y of var tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref {
	reghdfe `y' rsub_isic2_dummy age, absorb(i.ruc i.year##i.ccdd i.year##i.isic2 i.ccddpp##c.trend) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy age, absorb(i.ruc i.year##i.ccdd i.year##i.isic2 i.ccddpp##c.trend) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsublic_isic2_dummy age if (rsubotro_isic2_dummy==0 & rsubcobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccdd i.year##i.isic2 i.ccddpp##c.trend) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsubotro_isic2_dummy age if (rsublic_isic2_dummy==0 & rsubcobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccdd i.year##i.isic2 i.ccddpp##c.trend) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsubcobro_isic2_dummy age if (rsublic_isic2_dummy==0 & rsubotro_isic2_dummy==0), absorb(i.ruc i.year##i.ccdd i.year##i.isic2 i.ccddpp##c.trend) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2 i.ccddppdi##c.trend) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2 i.ccddppdi##c.trend) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsublic_isic2_dummy age if (rsubotro_isic2_dummy==0 & rsubcobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddpp i.year##i.isic2 i.ccddppdi##c.trend) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsubotro_isic2_dummy age if (rsublic_isic2_dummy==0 & rsubcobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddpp i.year##i.isic2 i.ccddppdi##c.trend) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsubcobro_isic2_dummy age if (rsublic_isic2_dummy==0 & rsubotro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddpp i.year##i.isic2 i.ccddppdi##c.trend) vce(cluster i.isic2_ccddppdi) noconstant
}

***Tables A.8 and A.9: Propensity score matching: Impact of eliminating sector-specific local entry barriers relative to matched counterfactual and balancing test:
foreach y of var tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref empl cap inv {
	bysort ruc: gen diff_`y' = `y' - L.`y'		/* first differencing */
	bysort ruc: egen xmean0812_`y' = mean(`y') if year<=2012		/* average outcome before 2012 as matching variable */
	bysort ruc: egen mean0812_`y' = max(xmean0812_`y')		/* average outcome before 2012: nonmissing values for all years */
	bysort ruc: egen xmeangr0812_`y' = mean(diff_`y') if year<=2012
	bysort ruc: egen meangr0812_`y' = max(xmeangr0812_`y')
	bysort ruc: egen xmean0912_`y' = mean(`y') if year>=2009 & year<=2012		/* average outcome before 2012 as matching variable */
	bysort ruc: egen mean0912_`y' = max(xmean0912_`y')		/* average outcome before 2012: nonmissing values for all years */
	bysort ruc: egen xmeangr0912_`y' = mean(diff_`y') if year>=2009 & year<=2012
	bysort ruc: egen meangr0912_`y' = max(xmeangr0912_`y')
	bysort ruc: egen xmean1012_`y' = mean(`y') if year>=2010 & year<=2012		/* average outcome before 2012 as matching variable */
	bysort ruc: egen mean1012_`y' = max(xmean1012_`y')		/* average outcome before 2012: nonmissing values for all years */
	bysort ruc: egen xmeangr1012_`y' = mean(diff_`y') if year>=2010 & year<=2012
	bysort ruc: egen meangr1012_`y' = max(xmeangr1012_`y')
	bysort ruc: egen xmean1112_`y' = mean(`y') if year>=2011 & year<=2012		/* average outcome before 2012 as matching variable */
	bysort ruc: egen mean1112_`y' = max(xmean1112_`y')		/* average outcome before 2012: nonmissing values for all years */
	bysort ruc: egen xmeangr1112_`y' = mean(diff_`y') if year>=2011 & year<=2012
	bysort ruc: egen meangr1112_`y' = max(xmeangr1112_`y')
	bysort ruc: egen xmean12_`y' = mean(`y') if year==2012		/* average outcome in 2012 */
	bysort ruc: egen mean12_`y' = max(xmean12_`y')		/* average outcome before 2012: nonmissing values for all years */
	bysort ruc: egen xmeangr12_`y' = mean(diff_`y') if year==2012
	bysort ruc: egen meangr12_`y' = max(xmeangr12_`y')
}
*Results:
preserve
keep if isic2==10 | isic2==36 | isic2==41 | isic2==42 | isic2==43 | isic2==47 | isic2==49 | isic2==50 | isic2==58 | isic2==60 | isic2==61 | isic2==92 | isic2==93		/* only reform sectors */
logit rsub_isic2_dummy mean1012_tfp_tl_ref mean1012_cap mean1012_empl mean1012_inv i.ccddpp, robust
predict pscore1, pr		/* estimate the propensity scores for each unit */
scalar cal = r(sd)*0.25 /* caliper = 1/4 of standard deviation of the pss */
egen exact = group(year isic2) if year>=2008
levelsof exact, local(cluster)
sum exact
gen weight = . 
gen att = .
gen weight_pw = . 
quietly foreach j of local cluster {
	psmatch2 rsub_isic2_dummy if exact==`j', pscore(pscore1) outcome(diff_tfp_tl_ref) caliper(`=scalar(cal)')
	replace weight_pw = _weight if exact==`j'
 }
psmatch2 rsub_isic2_dummy if ((weight_pw==. & rsub_isic2_dummy==1) | (rsub_isic2_dummy==0)), pscore(pscore1) outcome(diff_tfp_tl_ref) caliper(`=scalar(cal)')
replace weight_pw = weight_pw + _weight if (weight_pw!=. & _weight!=.) /* for control units that were already used in the within */
replace weight_pw = _weight if weight_pw ==. /* both treated and control that were unmatched in within */
reghdfe diff_tfp_tl_ref rsub_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_tfp_tl_ref rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_tfp_tl_ref rsublic_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_tfp_tl_ref rsubotro_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_tfp_tl_ref rsubcobro_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
pstest mean1012_tfp_tl_ref mean1012_cap mean1012_empl mean1012_inv if weight_pw!=., treated(rsub_isic2_dummy) mweight(weight_pw) raw rubin
restore
*
preserve
keep if isic2==10 | isic2==36 | isic2==41 | isic2==42 | isic2==43 | isic2==47 | isic2==49 | isic2==50 | isic2==58 | isic2==60 | isic2==61 | isic2==92 | isic2==93
logit rsub_isic2_dummy mean1012_tfp_cd_ref  mean1012_cap mean1012_empl mean1012_inv i.ccddpp, robust
predict pscore1, pr
scalar cal = r(sd)*0.25
egen exact = group(year isic2) if year>=2008
levelsof exact, local(cluster)
sum exact
gen weight = . 
gen att = .
gen weight_pw = . 
quietly foreach j of local cluster {
	psmatch2 rsub_isic2_dummy if exact==`j', pscore(pscore1) outcome(diff_tfp_cd_ref) caliper(`=scalar(cal)')
	replace weight_pw = _weight if exact==`j'
 }
psmatch2 rsub_isic2_dummy if ((weight_pw== .& rsub_isic2_dummy==1) | (rsub_isic2_dummy==0)), pscore(pscore1) outcome(diff_tfp_cd_ref) caliper(`=scalar(cal)')
replace weight_pw = weight_pw + _weight if (weight_pw!=. & _weight!=.)
replace weight_pw = _weight if weight_pw ==.
reghdfe diff_tfp_cd_ref rsub_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_tfp_cd_ref rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_tfp_cd_ref rsublic_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_tfp_cd_ref rsubotro_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_tfp_cd_ref rsubcobro_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
pstest mean1012_tfp_cd_ref mean1012_cap mean1012_empl mean1012_inv if weight_pw!=., treated(rsub_isic2_dummy) mweight(weight_pw) raw rubin
restore
*
preserve
keep if isic2==10 | isic2==41 | isic2==42 | isic2==43 | isic2==47 | isic2==49 | isic2==50 | isic2==58 | isic2==60 | isic2==61		/* no mean1012_markup_tl_ref obs for isic2==36, 92, 93 */
logit rsub_isic2_dummy mean1012_markup_tl_ref mean1012_cap mean1012_empl mean1012_inv i.ccddpp i.isic2, robust
predict pscore1, pr
scalar cal = r(sd)*0.25
egen exact = group(year) if year>=2008
levelsof exact, local(cluster)
sum exact
gen weight = . 
gen att = .
gen weight_pw = . 
quietly foreach j of local cluster {
	psmatch2 rsub_isic2_dummy if exact==`j', pscore(pscore1) outcome(diff_markup_tl_ref) caliper(`=scalar(cal)')
	replace weight_pw = _weight if exact==`j'
 }
psmatch2 rsub_isic2_dummy if ((weight_pw== .& rsub_isic2_dummy==1) | (rsub_isic2_dummy==0)), pscore(pscore1) outcome(diff_markup_tl_ref) caliper(`=scalar(cal)')
replace weight_pw = weight_pw + _weight if (weight_pw!=. & _weight!=.)
replace weight_pw = _weight if weight_pw ==.
reghdfe diff_markup_tl_ref rsub_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_markup_tl_ref rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_markup_tl_ref rsublic_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_markup_tl_ref rsubotro_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_markup_tl_ref rsubcobro_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
pstest mean1012_markup_tl_ref mean1012_cap mean1012_empl mean1012_inv if weight_pw!=., treated(rsub_isic2_dummy) mweight(weight_pw) raw rubin
restore
*
preserve
keep if isic2==10 | isic2==36 | isic2==41 | isic2==42 | isic2==43 | isic2==47 | isic2==49 | isic2==50 | isic2==58 | isic2==60 | isic2==61 | isic2==92 | isic2==93
logit rsub_isic2_dummy mean1012_markup_cd_ref mean1012_cap mean1012_empl mean1012_inv i.ccddpp, robust
predict pscore1, pr
scalar cal = r(sd)*0.25
egen exact = group(year isic2) if year>=2008
levelsof exact, local(cluster)
sum exact
gen weight = . 
gen att = .
gen weight_pw = . 
quietly foreach j of local cluster {
	psmatch2 rsub_isic2_dummy if exact==`j', pscore(pscore1) outcome(diff_markup_cd_ref) caliper(`=scalar(cal)')
	replace weight_pw = _weight if exact==`j'
 }
psmatch2 rsub_isic2_dummy if ((weight_pw== .& rsub_isic2_dummy==1) | (rsub_isic2_dummy==0)), pscore(pscore1) outcome(diff_markup_cd_ref) caliper(`=scalar(cal)')
replace weight_pw = weight_pw + _weight if (weight_pw!=. & _weight!=.)
replace weight_pw = _weight if weight_pw ==.
reghdfe diff_markup_cd_ref rsub_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_markup_cd_ref rsublic_isic2_dummy rsubotro_isic2_dummy rsubcobro_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_markup_cd_ref rsublic_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_markup_cd_ref rsubotro_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
reghdfe diff_markup_cd_ref rsubcobro_isic2_dummy age [fweight = weight_pw] if weight_pw!=., noabsorb vce(cluster i.isic2_ccddppdi) noconstant
pstest mean1012_markup_cd_ref mean1012_cap mean1012_empl mean1012_inv if weight_pw!=., treated(rsub_isic2_dummy) mweight(weight_pw) raw
restore

***Tables A.10: Robustness: Treated and control firms had comparable average pre-reform productivity levels:
gen yearisic2 = year * isic2
gen isic2ccddppdi = isic2 * ccddppdi
foreach y of var tfp_tl_ref tfp_cd_ref {
	logit rsub_isic2_dummy mean0812_`y' i.year##i.ccdd i.yearisic2 if year==2014, robust cluster(isic2ccddppdi)		/* meangr0812_`y' */
	logit rsub_isic2_dummy mean0812_`y' i.year##i.ccddpp i.yearisic2 if year==2014, robust cluster(isic2ccddppdi)
}

***Tables A.11: Robustness: Impact of eliminating all local entry barriers:
foreach y of var tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref {
	reghdfe `y' rsub_dummy age, absorb(i.ruc i.year##i.ccdd) vce(cluster i.ccddppdi) noconstant
	reghdfe `y' rsublic_dummy rsubotro_dummy rsubcobro_dummy age, absorb(i.ruc i.year##i.ccdd) vce(cluster i.ccddppdi) noconstant
	reghdfe `y' rsublic_dummy age if (rsubotro_dummy==0 & rsubcobro_dummy==0), absorb(i.ruc i.year##i.ccdd) vce(cluster i.ccddppdi) noconstant
	reghdfe `y' rsubotro_dummy age if (rsublic_dummy==0 & rsubcobro_dummy==0), absorb(i.ruc i.year##i.ccdd) vce(cluster i.ccddppdi) noconstant
	reghdfe `y' rsubcobro_dummy age if (rsublic_dummy==0 & rsubotro_dummy==0), absorb(i.ruc i.year##i.ccdd) vce(cluster i.ccddppdi) noconstant
	reghdfe `y' rsub_dummy age, absorb(i.ruc i.year##i.ccddpp) vce(cluster i.ccddppdi) noconstant
	reghdfe `y' rsublic_dummy rsubotro_dummy rsubcobro_dummy age, absorb(i.ruc i.year##i.ccddpp) vce(cluster i.ccddppdi) noconstant
	reghdfe `y' rsublic_dummy age if (rsubotro_dummy==0 & rsubcobro_dummy==0), absorb(i.ruc i.year##i.ccddpp) vce(cluster i.ccddppdi) noconstant
	reghdfe `y' rsubotro_dummy age if (rsublic_dummy==0 & rsubcobro_dummy==0), absorb(i.ruc i.year##i.ccddpp) vce(cluster i.ccddppdi) noconstant
	reghdfe `y' rsubcobro_dummy age if (rsublic_dummy==0 & rsubotro_dummy==0), absorb(i.ruc i.year##i.ccddpp) vce(cluster i.ccddppdi) noconstant
}

***Tables A.12: Robustness: Impact of eliminating all local entry barriers -- Test of parallel trend assumption:
foreach y of var tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref {
	***Province*year dummies:
	reghdfe `y' rsub_dummy F1.rsub_dummy F2.rsub_dummy F3.rsub_dummy F4.rsub_dummy F5.rsub_dummy age, absorb(i.ruc i.year##i.ccddpp) vce(cluster i.ccddppdi) noconstant
	test F2.rsub_dummy F3.rsub_dummy F4.rsub_dummy F5.rsub_dummy
	*
	reghdfe `y' rsublic_dummy rsubotro_dummy rsubcobro_dummy F1.rsublic_dummy F1.rsubotro_dummy F1.rsubcobro_dummy F2.rsublic_dummy F2.rsubotro_dummy F2.rsubcobro_dummy F3.rsublic_dummy F3.rsubotro_dummy F3.rsubcobro_dummy F4.rsublic_dummy F4.rsubotro_dummy F4.rsubcobro_dummy F5.rsublic_dummy F5.rsubotro_dummy F5.rsubcobro_dummy age, absorb(i.ruc i.year##i.ccddpp) vce(cluster i.ccddppdi) noconstant
	test F2.rsublic_dummy F3.rsublic_dummy F4.rsublic_dummy F5.rsublic_dummy
	test F2.rsubotro_dummy F3.rsubotro_dummy F4.rsubotro_dummy F5.rsubotro_dummy
	test F2.rsubcobro_dummy F3.rsubcobro_dummy F4.rsubcobro_dummy F5.rsubcobro_dummy
}

***Tables A.13: Robustness: Separate impacts of 2013 and 2014 reforms:
*2014
foreach y of var tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref {
	reghdfe `y' rsub14_isic2_dummy age, absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub14lic_isic2_dummy rsub14otro_isic2_dummy rsub14cobro_isic2_dummy age, absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub14lic_isic2_dummy age if (rsub14otro_isic2_dummy==0 & rsub14cobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub14otro_isic2_dummy age if (rsub14lic_isic2_dummy==0 & rsub14cobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub14cobro_isic2_dummy age if (rsub14lic_isic2_dummy==0 & rsub14otro_isic2_dummy==0), absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub14_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub14lic_isic2_dummy rsub14otro_isic2_dummy rsub14cobro_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub14lic_isic2_dummy age if (rsub14otro_isic2_dummy==0 & rsub14cobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub14otro_isic2_dummy age if (rsub14lic_isic2_dummy==0 & rsub14cobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub14cobro_isic2_dummy age if (rsub14lic_isic2_dummy==0 & rsub14otro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
}
*2013
foreach y of var tfp_tl_ref tfp_cd_ref markup_tl_ref markup_cd_ref {
	reghdfe `y' rsub13_isic2_dummy age, absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub13lic_isic2_dummy rsub13otro_isic2_dummy rsub13cobro_isic2_dummy age, absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub13lic_isic2_dummy age if (rsub13otro_isic2_dummy==0 & rsub13cobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub13otro_isic2_dummy age if (rsub13lic_isic2_dummy==0 & rsub13cobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub13cobro_isic2_dummy age if (rsub13lic_isic2_dummy==0 & rsub13otro_isic2_dummy==0), absorb(i.ruc i.year##i.ccdd i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub13_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub13lic_isic2_dummy rsub13otro_isic2_dummy rsub13cobro_isic2_dummy age, absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub13lic_isic2_dummy age if (rsub13otro_isic2_dummy==0 & rsub13cobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub13otro_isic2_dummy age if (rsub13lic_isic2_dummy==0 & rsub13cobro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
	reghdfe `y' rsub13cobro_isic2_dummy age if (rsub13lic_isic2_dummy==0 & rsub13otro_isic2_dummy==0), absorb(i.ruc i.year##i.ccddpp i.year##i.isic2) vce(cluster i.isic2_ccddppdi) noconstant
}

log close
